<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "hl_user_branch".
 *
 * @property int $id ID
 * @property int $br_id 行业分馆id
 * @property int $user_id 用户id
 * @property string $br_title 分馆名称
 * @property string $start_time 生效开始时间
 * @property string $end_time 失效时间
 * @property string $created_at 创建时间
 * @property string $updated_at 修改时间
 * @property string $deleted_at 删除时间
 * @property int $status 1有效  2无效
 */
class UserBranch extends \yii\db\ActiveRecord
{
    /**
     * 自动更新时间
     */
    public function behaviors()
    {
        return [
            [
                'class' => \yii\behaviors\TimestampBehavior::className(),
                'value' => function () {
                    return date('Y-m-d H:i:s');
                },
            ],
        ];
    }
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'hl_user_branch';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['br_id', 'user_id', 'status'], 'integer'],
            [['created_at', 'updated_at', 'deleted_at'], 'safe'],
            [['br_title', 'start_time', 'end_time'], 'string', 'max' => 255],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'br_id' => 'Br ID',
            'user_id' => 'User ID',
            'br_title' => 'Br Title',
            'start_time' => 'Start Time',
            'end_time' => 'End Time',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
            'deleted_at' => 'Deleted At',
            'status' => 'Status',
        ];
    }

    /**
     * 场景
     */
    const SCENARIOS_BANNER_INSERT = 'insert';

    public function scenarios()
    {
        $scenarios = [
            self::SCENARIOS_BANNER_INSERT => [
                'br_id',
                'user_id',
                'br_title',
            ],
        ];
        return array_merge(parent::scenarios(), $scenarios);
    }
}
